<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>短信项目模板审核</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../../layui/css/iconfont/iconfont.css" rel="stylesheet"
	type="text/css">
<link href="../../layui/css/layui.css" rel="stylesheet" type="text/css">
<link href="../../css/style.css" rel="stylesheet" type="text/css">
<script src="../../layui/layui.js"></script>
<script src="../../js/jquery-1.8.3.js"></script>
<script src="../../js/util.js"></script>
<script>
        layui.use(['form', 'jquery', 'element', 'laydate', 'layer'], function () {
            var form = layui.form;
            var $ = layui.$;
            var laydate = layui.laydate;
            var layer = layui.layer;
            var mgrId = getUrlParam("mgrId");
            var stationNum = getUrlParam("stationNum")+"个";
            var checkMgrId=getUrlParam("checkMgrId");
            var cityId = getUrlParam("cityId");
    		var countyId = getUrlParam("countyId");
    		var mgrName = getUrlParam("mgrName");
    		var mgrState = getUrlParam("mgrState");
    		var checkState = getUrlParam("checkState");
    		var openAccount = getUrlParam("openAccount");
    		var isArrearage = getUrlParam("isArrearage");
            laydate.render({
                elem: '#startTime'
            });
            laydate.render({
                elem: '#endTime'
            });
            laydate.render({
                elem: '#thresholdStartTime'
            });
            laydate.render({
                elem: '#thresholdEndTime'
            });
            laydate.render({
                elem: '#everyDayStartTime'
                , type: 'time'
                , btns: ['clear', 'confirm']
            });
            laydate.render({
                elem: '#everyDayEndTime'
                , type: 'time'
                , btns: ['clear', 'confirm']
            }); 

            $('#yes').on('click', function () {
            var param ;
            $.ajax({
                    type: 'post',
                    async: false,
                    url: '/util/findUser',
                    success: function (json) {
                        user=json;
    					if (json.duty == 0) {
    					  param = {
                    mgrId: mgrId,
                    state: 2,
                    remark: "通过"
                };}
                else if(json.duty == 1){
                	  param = {
                    mgrId: mgrId,
                    state: 1,
                    remark: "通过"
                };}
    			}});
                var url = '/templateCheck/check';
                $.ajax({
                    type: 'post',
                    async: false,
                    url: url,
                    data: param,
                    beforeSend: function () {
                        loading = layer.load(0, {shade: false});
                    },
                    success: function (json) {
                        layer.close(loading);
                        var data = json.data;
                        if (json.code == 0) {
                            layui.use('layer', function () {
                                layer.msg('审核成功', {/* 审核成功，点击确定按钮进行项目开启 */
                                    time: 0 //不自动关闭
                                    , btn: ['确定']
                                    , yes: function (index) {
                                        layer.close(index);
                                        location.href = "smsTemplateManage2.html?"+"mgrId="+mgrId+"&checkMgrId="+checkMgrId+"&cityId="+cityId+"&countyId="+countyId+"&mgrName="+mgrName
    													+"&mgrState="+mgrState+"&checkState="+checkState+"&openAccount="+openAccount+"&isArrearage="+isArrearage;
                                    }
                                });
                            });
                        } else {
                            layer.msg(json.msg);
                        }
                    }
                    ,
                    error: function (data) {
                        layer.msg('系统异常，请联系管理员处理!');
                    }
                });
            });

            $('#no').on('click', function () {
                var param = {
                    mgrId: mgrId,
                    state: 3,
                    remark: "不通过"
                };
                var url = '/templateCheck/check';
                $.ajax({
                    type: 'post',
                    async: false,
                    url: url,
                    data: param,
                    beforeSend: function () {
                        loading = layer.load(0, {shade: false});
                    },
                    success: function (json) {
                        layer.close(loading);
                        var data = json.data;
                        if (json.code == 0) {
                            layui.use('layer', function () {
                                layer.msg('审核成功，点击确定按钮返回审核管理界面', {
                                    time: 0 //不自动关闭
                                    , btn: ['确定']
                                    , yes: function (index) {
                                        layer.close(index);
                                        location.href = "smsTemplateManage2.html";
                                    }
                                });
                            });
                        } else {
                            layer.msg(json.msg);
                        }
                    }
                    ,
                    error: function (data) {
                        layer.msg('系统异常，请联系管理员处理!');
                    }
                });
            });



            //页面数据初始化
            $(document).ready(function () {
                var url = '/template2/findTemplate';
                var param = {
                    mgrId: mgrId
                };
                $.ajax({
                    type: 'post',
                    async: false,
                    url: url,
                    data: param,
                    beforeSend: function () {
                        loading = layer.load(0, {shade: false});
                    },
                    success: function (json) {
                        layer.close(loading);
                        var data = json.data;
                        $("#everyDayStartTime").val(data.everyDayStartTime);
                        $("#everyDayEndTime").val(data.everyDayEndTime);
                        $("#cycleThreshold").val(data.cycleThreshold);
                        $("#threshold").val(data.threshold);
                        $("#startTime").val(data.startDate);
                        $("#endTime").val(data.endDate);
                        $("#mgrName").val(data.name);
						$("#belong").val(data.belong);
						$("#content").val(data.content);
						$("#stationNum").val(stationNum);
                        if (data.realTime == 0) {
                            $("#realTime").val("立即发送");
                        }
                        else {
                            $("#realTime").val("延时"+data.realTime+"分钟");
                        }

                        if (data.isLocal == 0) {
                            $("#isLocal").val("本地发送");
                            $("#localDate").val(data.localDate+"天");
                            $("#province").hide();
                        } else if (data.isLocal == 1) {
                            $("#isLocal").val("本地不发送");
                            $("#localTime").hide();
                            if(data.isProvince == 0){$("#isProvince").val("省内发送");}
                            else{$("#isProvince").val("省内+省外");}
                        }else if(data.isLocal==2){
                            $("#isLocal").val("本地+外地");
                            $("#localDate").val(data.localDate+"天");
                            if(data.isProvince == 0){$("#isProvince").val("省内发送");}
                            else{$("#isProvince").val("省内+省外");}
                        }
                        var cycleMsg;
                        if (data.isThreshold == 0) {
                            cycleMsg = "没有设置阀值";
                        } else if (data.isThreshold == 1) {
                            cycleMsg = "发送总量为" + data.threshold + "条";
                        } else if (data.isThreshold == 2) {
                            if (data.cycle == 1) {
                                cycleMsg = "发送量为每年" + data.cycleThreshold + "条";
                            }
                            if (data.cycle == 2) {
                                cycleMsg = "发送量为每月" + data.cycleThreshold + "条";
                            }
                            if (data.cycle == 3) {
                                cycleMsg = "发送量为每周" + data.cycleThreshold + "条";
                            }
                            if (data.cycle ==4) {
                                cycleMsg = "发送量为每日" + data.cycleThreshold + "条";
                            }
                            if (data.cycle == 5) {
                                cycleMsg = "发送量为" + data.cycleThreshold + "条,时间范围:" +
                                    data.thresholdStartTime + "至" + data.thresholdEndTime;
                            }
                        } else if (data.isThreshold == 3) {
                            if (data.cycle == 1) {
                                cycleMsg = "发送总量为" + data.threshold + "条,周期发送量为每年" + data.cycleThreshold + "条";
                            }
                            if (data.cycle == 2) {
                                cycleMsg = "发送总量为" + data.threshold + "条,周期发送量为每月" + data.cycleThreshold + "条";
                            }
                            if (data.cycle == 3) {
                                cycleMsg = "发送总量为" + data.threshold + "条,周期发送量为每周" + data.cycleThreshold + "条";
                            }
                            if (data.cycle == 4) {
                                cycleMsg = "发送总量为" + data.threshold + "条,周期发送量为每日" + data.cycleThreshold + "条";
                            }
                            if (data.cycle == 5) {
                                cycleMsg = "发送总量为" + data.threshold + "条,周期发送量为" + data.cycleThreshold + "条,时间范围:" +
                                    data.thresholdStartTime + "至" + data.thresholdEndTime;
                            }
                        }
                        $("#threshold").text(cycleMsg);
                    }
                    ,
                    error: function (data) {
                        layer.msg('系统异常，请联系管理员处理!');
                    }
                });
            });
        });
    </script>
</head>
<body>
	<div class="layui-html-limit">
		<div class="layui-content-body">
			<div class="scroll-box">
				<div class="breadcrumb-box">
					<span class="layui-breadcrumb" lay-separator="|"> <a
						href="javascript:returnIndex2()">首页&nbsp;</a> <a href="">
							&nbsp;短信模板管理&nbsp; </a> <a href="smsTemplateManage2.html">
							&nbsp;短信项目模板配置管理</a> <a href=""> &nbsp;短信项目模板审核&nbsp; </a>
					</span>
				</div>
				<div class="content-box">
					<div class="layui-form layui-form-pane">
						<div class="layui-form-item">
							<div class="layui-block" pane="">
								<label class="layui-form-label">归属地</label>
								<div class="layui-input-block">
									<input type="text" style="width:auto" id="belong"
										autocomplete="off" class="layui-input" disabled>
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-block" pane="">
								<label class="layui-form-label">项目名称</label>
								<div class="layui-input-block">
									<input type="text" style="width:auto" id="mgrName"
										autocomplete="off" class="layui-input" disabled>
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-block">
								<label class="layui-form-label" style="width: auto">发送起止时间</label>
								<div class="layui-input-inline">
									<input type="text" name="date" id="startTime"
										autocomplete="off" class="layui-input" disabled>
								</div>
								<div class="layui-form-mid">-</div>
								<div class="layui-input-inline">
									<input type="text" name="date" id="endTime" autocomplete="off"
										class="layui-input" disabled>
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-block">
								<label class="layui-form-label" style="width:auto">每日发送时间段</label>
								<div class="layui-input-inline">
									<div class="layui-input-inline">
										<input type="text" name="date" id="everyDayStartTime"
											autocomplete="off" class="layui-input" disabled>
									</div>
								</div>
								<div class="layui-form-mid">-</div>
								<div class="layui-input-inline">
									<div class="layui-input-inline">
										<input type="text" name="date" id="everyDayEndTime"
											autocomplete="off" class="layui-input" disabled>
									</div>
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-block" pane="">
								<label class="layui-form-label">发送实时性</label>
								<div class="layui-input-block">
									<input type="text" style="width:auto" id="realTime"
										autocomplete="off" class="layui-input" disabled>
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-block" pane="">
								<label class="layui-form-label" style="width: auto">本地号码发送</label>
								<div class="layui-input-block">
									<input type="text" id="isLocal" autocomplete="off"
										class="layui-input" disabled style="width:auto">
								</div>
							</div>
						</div>
						<div class="layui-form-item" id="localTime">
							<div class="layui-block" pane="">
								<label class="layui-form-label" style="width: auto">本地发送保存时间</label>
								<div class="layui-input-block">
									<input type="text" id="localDate" autocomplete="off"
										class="layui-input" disabled style="width:auto">
								</div>
							</div>
						</div>
						<div class="layui-form-item" id="province">
							<div class="layui-block" pane="">
								<label class="layui-form-label" style="width: auto">外地发送范围</label>
								<div class="layui-input-block">
									<input type="text" id="isProvince" autocomplete="off"
										class="layui-input" disabled style="width:auto">
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-block" pane="">
								<label class="layui-form-label" style="width: auto">短信发送阀值</label>
								<div class="layui-input-block">
									<div id="threshold" class="text-autoWidth"></div>
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-block" pane="">
								<label class="layui-form-label">发送内容</label>
								<div class="layui-input-block">
									<input type="text" id="content" autocomplete="off"
										class="layui-input " text-autoWidth"" disabled>
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-block" pane="">
								<label class="layui-form-label">项目基站数</label>
								<div class="layui-input-block">
									<input type="text" id="stationNum" autocomplete="off"
										class="layui-input" disabled style="width:auto">
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<button class="layui-btn layui-btn-normal" id="yes">审核通过</button>
							<button class="layui-btn layui-btn-danger" id="no">审核不通过</button>
						</div>
					</div>
					<div>
						<h4 class="tips-h4">
							<i class="iconfont icon-xinxi"></i>提示:1.审核结果短信通知项目管理员和省公司管理员。 <br>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp2.只有审核流程结束后，才能修改短信内容。
						</h4>
					</div>
				</div>
			</div>
		</div>
	</div>
	</div>

</body>
</html>